package com.idcard.readcard.utils;

import android.os.SystemClock;
import android.util.Pair;
import android.view.View;

public class DoubleClickUtil {

    private static Pair<Integer, Long> clickPair = new Pair<Integer, Long>(0, 0L);

    public static void signleClick(View view, View.OnClickListener onClickListener) {
        view.setOnClickListener(v -> {
            if (v.getId() == clickPair.first && SystemClock.elapsedRealtime() - clickPair.second <= 1000){
                return;
            }
            clickPair = new Pair<Integer, Long>(v.getId(), SystemClock.elapsedRealtime());
            onClickListener.onClick(v);
        });
    }
}
